package com.example.myapplication;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.View;

public class MyView extends View {
    private Paint paint;
    public MyView(Context context,  AttributeSet attrs) {
        super(context, attrs);
        paint=new Paint();
        paint.setColor(Color.WHITE);
        paint.setStrokeWidth(20);
        paint.setStyle(Paint.Style.STROKE);
        //文字的大小
        paint.setTextSize(30);

    }
    @Override
    protected void onDraw(Canvas canvas){
        super.onDraw(canvas);
//五角红星
        //定义五个点的位置
       /* Point a=new Point(0,100);
        Point b=new Point(300,100);
        Point c=new Point(50,300);
        Point d=new Point(250,300);
        Point e=new Point(150,0);
        //连接五个点
        Path p=new Path();
        p.moveTo(a.x,a.y);
        p.lineTo(b.x,b.y);
        p.lineTo(c.x,c.y);
        p.lineTo(e.x,e.y);
        p.lineTo(d.x,d.y);
        p.lineTo(a.x,a.y);
        canvas.drawPath(p,paint);
        canvas.drawText("闪闪的红星",80,330,paint);
*/
    }
}
